#!/bin/sh

SRC_DIR="../appfs"
DST_FILE="app.img"
DST_DIR="/tftp/"
HTTP_DIR="/var/www/html/"
G_CHIP_TYPE="$1"
G_PROJECT_NAME="$2"

if [ ! -d "tools/$G_PROJECT_NAME/appfs" ];then
    exit
fi

echo "--------create appfs--------"
rm ../appfs/* -rf
git checkout ../appfs
cp tools/$G_PROJECT_NAME/appfs ../appfs -rf
chmod 777 ../appfs/ -R

echo ">>>>>> ###### rm $DST_FILE"
rm $DST_FILE

../com_mksquashfs.sh $G_CHIP_TYPE $SRC_DIR $DST_FILE

echo ">>>>>> ###### rm $DST_DIR$DST_FILE"
rm $DST_DIR$DST_FILE
echo ">>>>>> ###### rm $HTTP_DIR$DST_FILE"
rm $HTTP_DIR$DST_FILE

echo ">>>>>> ###### cp $DST_FILE $DST_DIR"
cp $DST_FILE $DST_DIR
echo ">>>>>> ###### cp $DST_FILE $HTTP_DIR"
cp $DST_FILE $HTTP_DIR

rm app_info*
g_sys_ver=`cat filesys/usr/ipcam/bak/soc_version.txt`
g_now_time=`date +%Y-%m-%d_%H-%M-%S`
touch app_info_$g_sys_ver'_'$g_now_time

